//杨辉三角II

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */


//1.滚动数组
//2.倒着往前加
//3.递推公式：C(n,m) = C(n-1,m)*(m-n+1)/(n)


// int* getRow(int rowIndex, int* returnSize)
// {
//     *returnSize = rowIndex+1;
//     int* ret = (int*)malloc(sizeof(int)*(rowIndex+1));
//     for(int i = 0; i<=rowIndex;++i)
//     {
//         if(i == 0)
//             ret[i] = 1;
//         else
//             ret[i] = (long long)ret[i-1]*(rowIndex-i+1)/i;
//     }
//     return ret;
// }

//翻转一句话中的单词III

#include<ctype.h>
void reserve(char* a,char* b)
{
    while(a<b)
    {
        char tmp = *a;
        *a = *b;
        *b = tmp;
        --b;++a;
    }
}


char * reverseWords(char * s)
{
    int len = strlen(s);
    reserve(s,s+len-1);
    char* pre = s;
    char* cur = s;
    while(*pre)
    {
        while(isspace(*pre))
            ++pre;
        cur = pre;
        while(isalnum(*cur))
            ++cur;
        if(cur>pre)
            reserve(pre,cur-1);
        pre = cur;
    }
}